import * as mars3d from 'mars3d'
import iconPng from '@/assets/image/定位.png'
// 矢量数据点
export const graphicPoint = graphicLayer => {
  let options = {
    position: { lat: 23.385288, lng: 116.496474, alt: 0 },
    style: {
      pixelSize: 20,
      color: '#ff0000',
      outline: true,
      outlineColor: '#ffffff',
      outlineWidth: 2
    },
    attr: {
      text: '这是矢量数据点'
    }
  }
  // 创建矢量数据 new mars3d.graphic.BaseGraphic(options)
  const graphic = new mars3d.graphic.PointEntity(options)
  graphicLayer.addGraphic(graphic)
}
/** 矢量数据文字*/
export const graphicLabel = graphicLayer => {
  let options = {
    position: { lat: 23.389663, lng: 116.502575, alt: 0 },
    style: {
      text: '这是矢量数据文字',
      scale: 1,
      fontColor: '#000000',
      font_family: '楷体',
      font_size: 24,
      font_weight: 'bolder',
      outline: true,
      outlineColor: '#ffffff',
      outlineWidth: 2
    },
    attr: {
      text: '这是矢量数据文字'
    }
  }
  const graphic = new mars3d.graphic.LabelEntity(options)
  graphicLayer.addGraphic(graphic)
}
// 矢量数据线
export const graphicLine = graphicLayer => {
  let options = {
    positions: [
      { lat: 23.38764, lng: 116.487992, alt: 0 },
      { lat: 23.389873, lng: 116.489797, alt: 10 }
    ],
    style: {
      width: 5,
      color: '#3388ff'
    },
    attr: {
      text: '这是矢量数据线'
    },
    minPointNum: 3
    // flyTo: true
  }
  const graphic = new mars3d.graphic.PolylineEntity(options)
  graphicLayer.addGraphic(graphic)
}
// 矢量数据面
export const graphicPolygon = graphicLayer => {
  let options = {
    positions: [
      { lat: 23.389397, lng: 116.512969, alt: 10 },
      { lat: 23.384338, lng: 116.515209, alt: 10 },
      { lat: 23.38994, lng: 116.505405, alt: 10 }
    ],
    style: {
      color: '#3388ff',
      opacity: 0.5,
      outline: true,
      outlineWidth: 3,
      outlineColor: '#ffffff'
    }
  }
  const graphic = new mars3d.graphic.PolygonEntity(options)
  graphicLayer.addGraphic(graphic)
}
// 矢量数据图标
export const graphicIcon = graphicLayer => {
  let options = {
    position: { lat: 23.397253, lng: 116.506671, alt: 0 },
    style: {
      image: iconPng,
      scale: 2,
      color: '#ff0000'
    }
  }
  const graphic = new mars3d.graphic.BillboardEntity(options)
  graphicLayer.addGraphic(graphic)
}
// 矢量数据模型
export const graphicModel = graphicLayer => {
  let options = {
    name: '汽车',
    position: { lat: 23.38, lng: 116.51, alt: 0 },
    style: {
      url: '//data.mars3d.cn/gltf/mars/jingche/jingche.gltf',
      scale: 16,
      minimumPixelSize: 100
    },
    popup: '如果是直接传参的popup,则不显示bindPopup中的attr'
  }
  const graphic = new mars3d.graphic.ModelEntity(options)
  const a = graphicLayer.addGraphic(graphic)
  console.log(a)
}
